﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using System.Text;
using System.Data.OracleClient;
using Maticsoft.DBUtility;

namespace Xiaov.SmartWeb.Application.TZ
{
  public partial class BBPLHZ : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!Page.IsPostBack)
      {
        string sql = "select distinct nf from bbtbqk";
        DataSet ds = DbHelperOra.Query(sql);
        ddlNF.DataTextField = "nf";
        ddlYF.DataValueField = "nf";
        ddlNF.DataSource = ds;
        ddlNF.DataBind();
        ddlNF.SelectedValue = DateTime.Now.Year.ToString();
        ddlYF.SelectedValue = DateTime.Now.Month.ToString();
      }
      Response.Write("<div id='mydiv' >");
      Response.Write("_");
      Response.Write("</div>");
      Response.Write("<script>mydiv.innerText = '';</script>");
      Response.Write("<script language=javascript>;");
      Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
      Response.Write("{var output; output = '正在汇总计算';dots++;if(dots>=dotmax)dots=1;");
      Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText =  output;}");
      Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ");
      Response.Write("timeID =window.setInterval('ShowWait()',1000);}");
      Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';");
      Response.Write("window.clearInterval(timeID );}");
      Response.Write("StartShowWait();</script>");
      Response.Flush();//这一句是最关键的

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
      string v_yf = "1";
      OracleParameter[] parameters ={
            new OracleParameter("v_nf",OracleType.VarChar,20),
　　     new OracleParameter("v_yf",OracleType.VarChar,20),
　　     new OracleParameter("isFinish",OracleType.VarChar,20)
　　      };
      parameters[0].Value = ddlNF.SelectedValue;
      parameters[1].Value = ddlYF.SelectedValue;
      parameters[2].Value = "false";
      parameters[2].Direction = ParameterDirection.Output;
      try
      {
        OracleDataReader odr = Maticsoft.DBUtility.DbHelperOra.RunProcedure("p_compute_all", parameters);
        v_yf = parameters[2].Value.ToString();
        odr.Close();
        if (v_yf == "true")
        {
          Label1.Text = "计算汇总完成";
        }
        else
        {
          Label1.Text = "返回错误";
        }
      }
      catch
      {

      }
    }
  }
}